/**
 * Created by lvlq on 16/3/12.
 */
module.exports.initPrize = function (req, res) {
    var Prize = M("index.prize");

    Prize.sync({
        force: true
    }).then(function () {
        return Prize.create({
            name: "京东5元购物券",
            num: 540,
            day_num: 30,
            zan_num: 3,
            has_num: 540
        });
    }).then(function () {
        return Prize.create({
            name: "京东30元购物券",
            num: 360,
            day_num: 20,
            zan_num: 10,
            has_num: 360
        });
    }).then(function () {
        return Prize.create({
            name: "ITO 24寸旅行箱",
            num: 5,
            day_num: 5,
            zan_num: 50,
            has_num: 5
        });
    }).then(function () {
        res.json({
            err: "ok"
        });
    }).catch(function (err) {
        res.json({
            err: err.message
        })
    });
};

module.exports.initRecord = function (req, res) {
    var Record = M("index.record");

    Record.sync({
        force: true
    }).then(function () {
        res.json({
            err: "ok"
        });
    }).catch(function (err) {
        res.json({
            err: err.message
        })
    });
};

module.exports.initUser = function (req, res) {
    var User = M("index.user");

    User.sync({
        force: true
    }).then(function () {
        res.json({
            err: "ok"
        });
    }).catch(function (err) {
        res.json({
            err: err.message
        })
    });
};


module.exports.initResult = function (req, res) {
    var Result = M("index.result");

    Result.sync({
        force: true
    }).then(function () {
        res.json({
            err: "ok"
        })
    }).catch(function (err) {
        res.json({
            err: err.message
        })
    });

};

module.exports.initTopList = function (req, res) {
    var TopList = M("index.toplist");

    TopList.sync({
        force: true
    }).then(function () {
        res.json({
            err: "ok"
        })
    }).catch(function (err) {
        res.json({
            err: err.message
        })
    });

};